jQuery(document).ready(function() {
	
      
      
      $("#Deletes").click(function(){
      	var flag = "false";
      	var idValue="";
		$("#tracks tbody :checkbox").each(function(i){
			if($(this).attr("checked")=="checked"){
				flag = "true";
				idValue = $(this).attr("value")+","+idValue;
			}
		});
		if(flag=="false"){
			alert("先选择你要删除的数据哦!");
		}else{
			if(confirm("警告!是否删除当前选中的数据?") == true){
				$.ajax({
    	            type:"post",
    	            url:"/crm/admin/track!deletes.action",
    	            dataType:"json",
    	            data:"ids="+idValue,
    	            cache:false,
    	            beforeSend:function(XMLHttpRequest){
    	            },
    	            success:function(json){
    	            	result = json.result;
    	            	if(result){
    	            		alert("删除成功");
    	            		window.location.href="/crm/admin/track!list.action";
    	            	}else{
    	            		alert("程序异常,请与开发人员联系!");
    	            	}
    	            },
    	           	complete:function(XMLHttpRequest,textStatus){
    	           	},
    	          	error:function(XMLHttpRequest,textStatus,errorThrown){
    	                   alert("网络错误，请稍后重试!");
    	          	}
                });
			}
		}
      });
      
      /**
       * 复制
       */
      $("#Duplicate").click(function(){
    	  
      });
      
      /**
       * 导出
       */
      $("#Export").click(function(){
    	  
    	  
      });
      /**
       * 导入
       */
      $("#Import").click(function(){
		  
      });
}); 

/**
 * 查看
 */
  function viewTracks(id){
	  $.ajax({
          type:"post",
          url:"/crm/admin/track!findById.action",
          dataType:"json",
          data:"trackId="+id,
          cache:false,
          beforeSend:function(XMLHttpRequest){
          },
          success:function(json){
        	  result = json.result;
        	  if(result){
        		  tracks = json.tracks;
        		  customerName = json.customerName;
        		  customerId = json.customerId
        		  $("#customer_id").val(customer_id);
        		  $("#CUSTO_NAME").val(customerName);
        		  $("#theme").val(tracks.theme);
        		  $("#contacts_name" ).empty();
 			      $("#contacts_name" ).append( "<option value='"+customerId+"'>" +customerName+"</option>" );
        		  $("#track_time").val(tracks.trackTime);
        		  $("#track_ways").val(tracks.trackWays);
        		  $("#before_track_step").val(tracks.beforeTrackStep);
        		  $("#after_track_step").val(tracks.afterTrackStep);
        		  $("#catagory").val(tracks.catagory);
        		  $("#tracker").val(tracks.tracker);
        		  $("#next_track_time").val(tracks.nextTrackTime);
        		  $("#track_detail").val(tracks.trackDetail);
        		  $("#SUBMIT").attr("disabled",true);
        		  $("#ViewTracking").modal("show");
        	  }else{
        		  alert("程序异常,请联系开发人员!");
        	  }
              
          },
         	complete:function(XMLHttpRequest,textStatus){
         	},
        	error:function(XMLHttpRequest,textStatus,errorThrown){
              alert("网络错误,重稍后重试!");
        	}
      });
  }
